/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.mathematica;

/**
 *
 * @author Mr.Sam
 */
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyVetoException;
import java.util.*;
import fr.ove.openmath.mathematica.*;
import fr.ove.palette.swing.*;
import fr.ove.utils.*;

public class TestWorkBook extends JFrame {
    WorkBook workBook;
    MyMenuBar menuBar;
    ConnectionConfigDialog ccd;
    
    public TestWorkBook() {
        //new SplashScreen("cow.gif", this, 4000);
        
        StatusBar statusBar = new StatusBar(this);
        
        ConnectionFactory factory = new ConnectionFactory();
        workBook = new WorkBook(factory, statusBar);
        
        OpenMathViewer omViewer = new OpenMathViewer(workBook);
        JPaletteEditor palette = new JPaletteEditor();
        palette.setFont(new Font("Dialog", Font.PLAIN, 12));
        workBook.addPalette("Palette Editor", palette);
        
        ccd = new ConnectionConfigDialog(this, factory);
        menuBar = new MyMenuBar(workBook, omViewer, ccd);
        setJMenuBar(menuBar);
        workBook.addChangeListener(menuBar);
        
        JPanel topPanel = new JPanel(new BorderLayout());
        PanelCommand panelCommand = new PanelCommand(omViewer, palette);
        workBook.addChangeListener(panelCommand);
        topPanel.add(panelCommand, BorderLayout.SOUTH);
        ToolBar toolBar = new ToolBar(workBook, omViewer, palette, panelCommand);
        workBook.addChangeListener(toolBar);
        topPanel.add(toolBar, BorderLayout.NORTH);
        
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        contentPane.add(workBook, BorderLayout.CENTER);
        contentPane.add(topPanel, BorderLayout.NORTH);
        contentPane.add(statusBar, BorderLayout.SOUTH);

        
        addWindowListener(
            new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    System.exit(0);
                }
            }
        );
    }
    
    public static void main(String args[]) {
        TestWorkBook tif = new TestWorkBook();
        tif.setBounds(0,0,850,550);
        tif.setVisible(true);
    }
}